package edu.ctbu.hello.service;

import edu.ctbu.hello.dao.StudentRepository;
import edu.ctbu.hello.domain.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {

    @Autowired
    private StudentRepository studentRepository;

    public List<Student> findAll() {

        return studentRepository.findAll();
    }

    public List<Student> findByName(String name) {
        return studentRepository.findByName(name);
    }

    public void deleteById(Integer id) {
        Student student = studentRepository.findById(id).get();
        studentRepository.delete(student);
    }


}
